﻿using DalatCooking.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DalatCooking.Core.Helper;
public partial class admin_Setting_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        //  LoadConfig();
        // LoadTheme();
        base.OnInit(e);
        if (!IsPostBack)
        {
            Person p = Session.GetPersonLogged();
            if (!p.IsInRole("SuperUser"))
                Response.Redirect("/admin/accessdeny.aspx");
        }
    }
    void LoadConfig()
    {
       // txtSiteName.Text = Setting.String("SITE_NAME");
       // txtSiteUrl.Text = Setting.String("SITE_URL");
       // txtPostsPerPage.Text = Setting.String("site.pagesize");
       

      //  txtLogo.Text = Setting.String("SITE_LOGO");
      
        //txtAddress.Text = Setting.String("SITE_ADDRESS");
       // txtEmail.Text = Setting.String("SITE_EMAIL");
      //  txtPhone.Text = Setting.String("SITE_PHONE");
      //  txtYahoo.Text = Setting.String("SITE_YM");        
      //  txtSkype.Text = Setting.String("SITE_SKYPE");
    }
    void LoadTheme()
    {
        DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/themes/"));
        foreach (DirectoryInfo d in dir.GetDirectories())
        {
            ddlTheme.Items.Add(new ListItem(d.Name, d.Name));
        }
        ddlTheme.SelectedValue = Setting.String("SITE_THEME");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // AppConfig.Instance().SetValue("sitename", txtName.Text);
        // AppConfig.Instance().SetValue("pagesize", txtPostsPerPage.Text);
       // Setting.SetValue("SITE_NAME", txtSiteName.Text);
      //  Setting.SetValue("site.pagesize", txtPostsPerPage.Text);
       // Setting.SetValue("site.theme", ddlTheme.SelectedValue);
       // Setting.SetValue("site.logo", txtLogo.Text);
        //Response.Redirect(Request.RawUrl);
    }
}